import { Entity, PrimaryGeneratedColumn, Column, CreateDateColumn, UpdateDateColumn, ManyToOne } from 'typeorm';
import { Category } from './Category';

@Entity('listening_materials')
export class ListeningMaterial {
  @PrimaryGeneratedColumn()
  id: number;

  @Column()
  title: string;

  @Column('text')
  description: string;

  @Column()
  audioUrl: string;

  @Column({ default: 0 })
  duration: number;

  @Column({ default: 1 })
  difficulty: number;

  @Column({ default: false })
  isPublished: boolean;

  @ManyToOne(() => Category, category => category.listeningMaterials)
  category: Category;

  @Column({ type: 'json', nullable: true })
  transcript: {
    text: string;
    timestamps: { start: number; end: number; text: string }[];
  };

  @CreateDateColumn()
  createdAt: Date;

  @UpdateDateColumn()
  updatedAt: Date;
} 